<template>
  <div class="row">
      <h2 v-if="firstView">根据关键字收索GitHub用户名称</h2>
      <h2 v-else-if="loading">正在请求中请等待...</h2>
      <h2 v-else-if="errorMsg" :style="{color: hotpink}">{{errorMsg}}</h2>
    <div class="card" v-for="user in users" :key="user.userName">
      <a :href="user.url" target="_blank">
        <img
          :src="user.avatar_url"
          style="width: 100px"
        />
      </a>
      <p class="card-text">{{user.userName}}</p>
    </div>
  </div>
</template>

<script>
// 引入需要的数据
import {mapState} from 'vuex'
export default {
  name: "Main",
  computed:{
    ...mapState['firstView','loading','users','errorMsg']
  }
};
</script>

<style scoped>
.card {
  float: left;
  width: 33.333%;
  padding: 0.75rem;
  margin-bottom: 2rem;
  border: 1px solid #efefef;
  text-align: center;
}

.card > img {
  margin-bottom: 0.75rem;
  border-radius: 100px;
}

.card-text {
  font-size: 85%;
}
</style>
